package com.zhongwang.business.module.menu.service;

import com.zhongwang.business.gen.entity.User;
import com.zhongwang.business.module.basic.model.SysUserModel;
import com.zhongwang.business.module.menu.dao.MenuDao;
import com.zhongwang.business.module.menu.model.AccountingItemCountModel;
import com.zhongwang.business.module.quoteManage.quoteManageDao.QuotationApproveDao;
import com.zhongwang.business.util.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 徐一贺
 * @className AccountingService
 * @description 菜单栏核算业务逻辑层
 * @date 2020/11/19 16:50
 * @versron ver 1.0
 */
@Service
public class MenuService {

    @Autowired
    private MenuDao dao;
    @Autowired
    private QuotationApproveDao quotationApproveDao;

    /**  getItemCountAccounting 获取核算菜单项数据数量
     * @param
     * @return com.zhongwang.business.common.JsonResult
     * @exception
     * @author 徐一贺
     * @date 2020/11/19 16:58
     */
    public AccountingItemCountModel getItemCountAccounting() {
        AccountingItemCountModel param = new AccountingItemCountModel();
        param.setCurrentUserId(ShiroUtils.getUserId());
        param.setCurrentUserName(ShiroUtils.getUser().getName());
        param.setCurrentUserAccount(ShiroUtils.getUser().getAccount());
        param.setCompletePermission(dao.selectCompletePermission(ShiroUtils.getUser().getAccount()));
        SysUserModel sysUserModel = quotationApproveDao.findNowNodeByAccount(ShiroUtils.getUser().getAccount());
        AccountingItemCountModel data = new AccountingItemCountModel();
        //获取菜单栏 - 待核算任务数目
        data.setAccountTaskCount(dao.getAccountTaskCount(param));
        //获取菜单栏 - 待提交核算任务数目
        data.setAccountSubmitCount(dao.getAccountSubmitCount(param));
        //获取菜单栏 - 待审核核算任务数目
        data.setAccountApprovalCount(dao.getAccountApprovalCount(param));
        //获取菜单栏 - 待提交款票数目
        data.setAccountKPSubmitCount(dao.GetAccountKPSubmitCount(param));
        //获取菜单栏 - 待审核款票数目
        data.setAccountKPExamineCount(dao.GetAccountKPExamineCount(param));
        //获取菜单栏 - 报价待提交数量
        data.setQuoteUnSubmitCount(dao.selectQuoteUnSubmitCount(param));
        //获取菜单栏 - 报价待审核数量
        data.setQuoteUnApproveCount(dao.selectQuoteUnApproveCount(sysUserModel.getVerifyInfoId()));
        //获取菜单栏 - 报价待确认数量
        data.setQuoteUnConfirmCount(dao.selectQuoteUnConfirmCount(param.getCompletePermission()));
        return data;
    }
}
